<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>账户管理</title>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/base_v3.0.css">
<link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/themes.css">
<link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/colpick.css">
<link href="http://ui.fcstatic.naryou.cn/static/libs/easyui/themes/icon.css" rel="stylesheet" type="text/css" />
<link  style="width:16px; height=16px;" rel="shortcut icon" href="/static/new_ui/images/logo_s.png">
<script type="text/javascript" src="/static/new_ui/new_js/jquery.js"></script>
<script type="text/javascript" src="/static/libs/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/new_ui/new_js/base_v3.0.js"></script>
<script type="text/javascript" src="/static/new_ui/new_js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/new_ui/new_js/build.js"></script>
<script type="text/javascript" src="/static/new_ui/new_js/css3-mediaqueries.js"></script>
<script type="text/javascript" src="/static/new_ui/new_js/themes.plugin.js"></script>

<link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/datepicker.css">
<script type="text/javascript" src="/static/new_ui/new_js/datepicker.js"></script>
<script type="text/javascript" src="/static/new_ui/new_js/pagelation.js"></script>
<script type="text/javascript" src="/static/new_ui/new_js/zepto.touchwipe.min.js"></script>
<script type="text/javascript" src="/static/new_ui/new_js/colpick.js"></script>
<script type="text/javascript">
$.extend({  //jquery extend
	turnOnAjax:function(flag,str) {
	   
		var html = "<div class='modal-backdrop fade in' id='ajaxloadimg' style='z-index:20000'><center><img src='/static/new_ui/img/ajaxloadimg.gif' style='margin: auto;width: 50px;margin-top: 20%;'><p style='color: white;font-weight: bold;'>"+str+"</p></center></div>"
		if(flag == 'on'){
			$("body").append(html)
		}else{
			$("#ajaxloadimg").remove();
		}
		},
});

</script>


</head>
<body>
<div class="container-fluid warp tops">
    <h1 class="page-headers no-icon">
        账户管理&nbsp;&nbsp;&nbsp;
        <span class="current">
            <span style="width:560px"><i style="margin-left:-192px"></i>管理员可以查看有多少人可以登录后台，并可以删除用户</span>
        </span>
    </h1>
    <div class="row-fluid">
        <ul id="myTab" class="nav nav-tabs">
            <li class="active"><a href="#daiqianyue" data-toggle="tab" onclick="loadData('dev')">账户列表</a></li>
        </ul>
        <div id="myCustom" class="tab-content single-content no-top-border no-th-border">
            <div class="tab-pane fade in active" id="daiqianyue">
                <div class="right-btn">
                    <a class="button btn-success btn-w140 btn-h30" href="#firstPopup" data-toggle="modal" onclick="initSelectData(1, false, 'addDevRole');">创建账户</a>
                </div>
                <form></form>
                <table class="table">
                    <tr>
                        <th>账户</th>
                        <th>操作</th>
                    </tr>
                <% if (users.length != 0) { %>
                <% users.forEach(function (user, index) { %>
                    <tr>
                        <td><%= user.name %></td>
                        <td><a href="/removeOneuser/<%= user._id %>">删除</a></td>
                    </tr>
                     <% }) %>
            <% } else { %>
            <h3 class="text-center">您还未发布任何信息</h3>
            <% } %>
                </table>
            </div>

        </div>
    </div>
    <!--弹出层-->
    <!--创建开发商角色-->
    <div id="firstPopup" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h3 class="PopupTitle">创建管理员账户</h3>
        </div>
        <div class="modal-body">
         <form action="regist" method="post">
            <div class="input-cont2" id="addnameWrongDiv">
                <p>
                    <span class="clip-popup-font w65 color-0">用户名：</span>
                    <input type="text" class="in-text2 h40 w220" id="addname" onkeyup="validateName(this)" onkeypress="validateName(this)" name="name">
                    <span class="txt-num"><i id="addnameWrongLength">0</i>/<i> 10</i></span><span class="value-wrong" id="addnameWrong" ></span>
                </p>
            </div>

            <div class="input-cont2" id="addpasswordfWrongDiv">
                <p>
                    <span class="clip-popup-font w65 color-0">登录密码：</span><input type="password" class="in-text2 h40 w220" id="addpassword" name="password"> <span class="value-wrong" id="addpasswordfWrong"></span>
                </p>
            </div>

         
        </div>
        <div class="modal-footer">
            <button class="button btn-success btn-w100" type="submit" onclick="addDevUser(this);">确定</button>
            <button class="button btn-gray btn-w100" data-dismiss="modal" aria-hidden="true">取消</button>
        </div>
    </form>
    </div>


</div>
<script>

    var currentOrgId = 0;
    var saleDataRow = 0;
    var salOrgId = "248";
    var devOrgId = "248";
    $(function() {
        $(".head .radios-module a").on('click', function() {
            var num = $(this).attr('data-num');
            var $modalBody = $(this).parents('.modal-body');
            if (num == 'one') {
                $modalBody.find('.nav-hint').hide();
                $modalBody.find('.add-info').show();
            } else {
                $modalBody.find('.add-info').hide();
                $modalBody.find('.nav-hint').show();
            }
        });

        $(".sell-group li").live('click', function() {
            $(".sell-group li").removeClass('current');
            $(this).addClass('current');
        });
        
        
    })

    function developer() {
        $('#daiqianyue').pageLation(
                {
                    container : "#daiqianyue",//table外面的div对象的ID
                    url : '/merse/operator/search.htm/V3.0',//请求地址
                    pageForm : "",//附加条件的form表单
                    param : {
                        orgName : "开发商组"
                    },
                    success : function(msg, o) {
                        var str = "";
                        for (var i = 0; i < msg.length; i++) {
                            var row = msg[i];
                            var role = "";
                            var flagR = false;
                            var mrow = msg[i].operatorRoles;
                            for (var j = 0; j < mrow.length; j++) {
                                role += mrow[j].role.name;
                                if (mrow[j].role.id == 1) {
                                    flagR = true;
                                }
                                if (j < mrow.length - 1)
                                    role += ',';
                            }
                            str += '<tr>' + '<td>' + row.account + '</td>' + '<td>' + (row.name == null ? "" : row.name) + '</td>' + '<td>' + (row.telephone == null ? "" : row.telephone) + '</td>'
                                    + '<td>' + role + '</td>' + '<td>';
                            if (!flagR) {
                                str += '<a class="pass color-green"  href="#eighthPopup" data-toggle="modal" onclick="initSelectData(1, true, \'editSaleRole\',' + row.id + ');">编辑</a>';
                            }
                            if (!flagR) {
                            	if('297'!=row.id){
                                    if (row.status.value == 1) {
                                        str += '<a class="pass color-red" data-toggle="modal" onclick="freezeUserOperation(' + row.id + ',1);">冻结</a></td>';
                                    } else {
                                        str += '<a class="pass color-red" data-toggle="modal" onclick="unFreezeOperator(' + row.id + ',1);">解冻</a></td>';
                                    }
                            	}
                            }
                            str += "</tr>";
                        }
                        $.appendData(str, o);
                    }
                });
    }

    function sale() {
        initSalorGroup();
        inSaleData(currentOrgId);
    }
    //初始化分组数据
    function inSaleData(orgId) {
        currentOrgId = orgId;
        saleDataRow = 0;
        $('#yanqiqianyue').pageLation(
                {
                    container : "#yanqiqianyue",//table外面的div对象的ID
                    url : '/merse/operator/searchsalor.htm/V3.0',//请求地址
                    pageForm : "",//附加条件的form表单
                    param : {
                        orgId : orgId
                    },
                    success : function(msg, o) {
                        var str = "";
                        saleDataRow = msg.length;
                        for (var i = 0; i < msg.length; i++) {
                            var row = msg[i];
                            var role = "";
                            var mrow = msg[i].operatorRoles;
                            if (row.flag == "2") {
                                role = "置业顾问";
                            } else {
                                for (var j = 0; j < mrow.length; j++) {
                                    role += mrow[j].role.name;
                                    if (j < mrow.length - 1)
                                        role += ',';
                                }
                            }
                            if (row.flag == "2") {
                                str += '<tr>' + '<td>' + row.account + '</td>' + '<td>' + row.name + '</td>' + '<td>' + (row.telephone == "null"  ? "" : row.telephone) + '</td>' + '<td>' + role
                                        + '</td>' + '<td><a class="pass color-green" href="#seventhPopup" data-toggle="modal" onclick="editBuilding(' + row.id + ');">编辑</a>';
                                str += '<a class="pass color-red" data-toggle="modal" href="#sixthPopup" onclick="doBuildingDele(\'' + row.name + '\',' + row.id + ');">删除</a></td></tr>';

                            } else {
                                str += '<tr>' + '<td>' + row.account + '</td>' + '<td>' + row.name + '</td>' + '<td>' + (row.telephone == "null" ? "" : row.telephone) + '</td>' + '<td>' + role
                                        + '</td>' + '<td><a class="pass color-green" href="#eighthPopup" data-toggle="modal" onclick="initSelectData(2, true, \'editSaleRole\',' + row.id
                                        + ');">编辑</a>';
                                if (row.status.value == 1) {
                                    str += '<a class="pass color-red" data-toggle="modal" onclick="freezeUserOperation(' + row.id + ',2);">冻结</a></td></tr>';
                                } else {
                                    str += '<a class="pass color-red" data-toggle="modal" onclick="unFreezeOperator(' + row.id + ',2);">解冻</a></td></tr>';
                                }

                            }

                        }
                        $.appendData(str, o);
                    }
                });
        
       

    }
    function loadData(type) {
        if (type == "dev") {
            developer();
        } else if (type == "sal") {
            sale();
        } else {
            developer();
        }
    }
    //加载数据
    loadData();

    function doAddSaleGroup() {
        $("#saleGroup").val("");
        $("#addSaleGroupWrongLength").html(0);
        $("#addSaleGroupDiv").removeClass("wrong");
        $("#addSaleGroupWrong").html('');
    }
    //添加销售组
    function addSaleGroup(obj) {
        if ($.trim($("#saleGroup").val()) == "") {
            $("#addSaleGroupDiv").addClass("wrong");
            $("#addSaleGroupWrong").html("销售分组名称不能为空");
            return;
        } else {
            $("#addSaleGroupDiv").removeClass("wrong");
            $("#addSaleGroupWrong").html("");
        }

        if (!validateGroup($("#saleGroup"))) {
            return;
        }
        $.ajax({
            type : "POST",
            dataType : "html",
            url : "/se/org/create.htm",
            data : {
                orgName : "销售组",
                saleGroup : $("#saleGroup").val()
            },
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                if (result.success) {
                    statusInfo($(obj), 1, "操作成功");
                } else {
                    $("#addSaleGroupDiv").addClass("wrong");
                    $("#addSaleGroupWrong").html(result.msg);
                }
                //刷新页面
                loadData('sal');
            }
        });
    }

    function doUpdateSaleGroup(orgId, orgName) {
        $("#saleTxtGroup").val(orgName);
        $("#eidtSalorGroupId").val(orgId);
        $("#editSaleGroupWrongLength").html(orgName.length);
        $("#editSaleGroupDiv").removeClass("wrong");
        $("#editSaleGroupWrong").html('');
    }

    function doDeleteSaleGroup(orgId, orgName) {

        $("#confrimOrgGroup").html("确认删除：" + orgName + "?");
        $("#deleteOrgGroupId").val(orgId);
    }

    //删除销售组
    function deleteSaleGroup(obj) {
        if (saleDataRow > 0) {
            statusInfo($(obj), 2, "该分组下面存在用户,请先删除用户！");
            return;
        }
        $.ajax({
            type : "POST",
            dataType : "html",
            url : "/se/org/delete.htm",
            data : {
                orgId : $("#deleteOrgGroupId").val()
            },
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                if (result.success) {
                    statusInfo($(obj), 1, "操作成功");
                } else {
                    saveResult(false, result.msg);
                    //alert("操作失败:" + result.msg);
                }
                //刷新页面
                loadData('sal');
            }
        });
    }

    //更新销售组
    function updateSaleGroup(obj) {
        if ($.trim($("#saleTxtGroup").val()) == "") {
            $("#editSaleGroupDiv").addClass("wrong");
            $("#editSaleGroupWrong").html('销售分组名称不能为空');
            return;
        } else {
            $("#editSaleGroupDiv").removeClass("wrong");
            $("#editSaleGroupWrong").html();
        }

        if (!validateEditGroup($("#saleTxtGroup"))) {
            return;
        }
        $.ajax({
            type : "POST",
            dataType : "html",
            url : "/se/org/update.htm",
            data : {
                orgId : $("#eidtSalorGroupId").val(),
                orgName : $("#saleTxtGroup").val()
            },
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                if (result.success) {
                    statusInfo($(obj), 1, "操作成功");
                } else {
                    saveResult(false, result.msg);
                    //alert("操作失败:" + result.msg);
                }
                //刷新页面
                loadData('sal');
            }
        });
    }

    //初始化销售分组
    function initSalorGroup() {
        var url = "/se/org/list/";
        $.ajax({
            url : url,
            async : false,
            type : 'post',
            dataType : 'json',
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                var str = "";
                var selectstr = ""; //初始化下拉列表的值
                $("#salorGroup").empty();
                for (var i = 0; i < result.length; i++) {
                    var row = result[i];
                    if (i == 0) {
                        currentOrgId = row.id;
                        str += '<li class="pull-left current" onclick="inSaleData(' + row.id + ')">' + '<span class="group-name">' + row.orgName + '</span>' + '<span class="ico">'
                                + '<a class="edit" href="#forthPopup" data-toggle="modal" onclick="doUpdateSaleGroup(' + row.id + ',\'' + row.orgName + '\')"><span></span></a>'
                                + '<a class="del" href="#fifthPopup" data-toggle="modal"  onclick="doDeleteSaleGroup(' + row.id + ',\'' + row.orgName + '\')"><span></span></a></span></li>';
                    } else {
                        str += '<li class="pull-left" onclick="inSaleData(' + row.id + ')">' + '<span class="group-name">' + row.orgName + '</span>' + '<span class="ico">'
                                + '<a class="edit" href="#forthPopup" data-toggle="modal"onclick="doUpdateSaleGroup(' + row.id + ',\'' + row.orgName + '\')"><span></span></a>'
                                + '<a class="del" href="#fifthPopup" data-toggle="modal" onclick="doDeleteSaleGroup(' + row.id + ',\'' + row.orgName + '\')"><span></span></a></span></li>';
                    }
                    selectstr+="<li><a href='javascript:void(0);' hrefvalue='"+row.id+"' onclick='selectLi(this)'>"+row.orgName+"</a></li>";
                    
                }
                $("#salorGroup").append(str);
                $(".select-min").empty().append(selectstr);
            }
        });
    }

    //初始化数据   
    function initSelectData(type, isEdit, roleDiv, operatorId) {
    	if (type == 1) {
            $("#eighthPopup").find(".market-group").hide();
        } else if (type == 2) {
        	$("#eighthPopup").find(".market-group").show();
        }
        $("#editType").val(type);
        
        if (isEdit) {
            //查询数据
            var operator = getOperatorData(operatorId);
            $("#editName").val(operator.name);
            $("#editTelephone").val(operator.telephone);
            $("#editAccount").val(operator.account);
            $("#editOperatorId").val(operatorId);
            $("#passwordInfo").html("（重置后密码为123456）");
            if (operator.name != null && operator.name != "") {
                $("#editnameWrongLength").html(operator.name.length);
            } else {
                $("#editnameWrongLength").html("0");
            }
            $("#editnameWrongDiv").removeClass("wrong");
            $("#editnameWrong").html('');
            $("#editTelephoneWrongDiv").removeClass("wrong");
            $("#editTelephoneWrong").html('');
            $("#editAccountWrong").html(operator.account.length);

            if (type == 1) {
                $("#editOperator").html("编辑开发商账户");
                $("#eighthPopup").hide();
                listRole(operator, 1, roleDiv);
            } else if (type == 2) {
                $("#editOperator").html("编辑销售账户");
                $("#eighthPopup .modal-body market-group").show();
                listRole(operator, 2, roleDiv);
            }
          //设置修改销售管理层下拉菜单的默认值     
            $("#eighthPopup").find(".dropdown-list .select-min li").each(function(){
                if($(this).children().attr("hrefvalue")==currentOrgId){
                	$("#eighthPopup").find(".dropdown-list .drop-list-min .checked a").text($(this).children().text());
                	$("#eighthPopup").find("#saleTeam").val($(this).children().attr("hrefvalue"));
                }
            });
        } else {
            if (type == 1) {
                $("#addname").val("");
                $("#addaccount").val("");
                $("#addpassword").val("");
                $("#addconfrimpassword").val("");
                $("#addtelephone").val("");
                $("#accountLength").html("0");
                $("#addaccountWrongDiv").removeClass("wrong");
                $("#addaccountWrong").html('');
                $("#addnameWrongLength").html("0");
                $("#addnameWrongDiv").removeClass("wrong");
                $("#addnameWrong").html('');
                $("#addpasswordWrongDiv").removeClass("wrong");
                $("#addpasswordWrong").html("");
                $("#addtelephoneWrongDiv").removeClass("wrong");
                $("#addtelephoneWrong").html("");
                listRole(null, 1, roleDiv)
            } else if (type == 2) {
                if (currentOrgId == 0) {
                    saveResult(false, "请先创建销售分组");
                    return;
                }
                $("#remark").val("");
                $("#addsalname").val("");
                $("#addsalaccount").val("");
                $("#addsalpassword").val("");
                $("#addsalconfrimpassword").val("");
                $("#addsaltelephone").val("");

                $("#saleaccountLength").html("0");
                $("#addsaleaccountWrongDiv").removeClass("wrong");
                $("#addsaleaccountWrong").html('');
                $("#addsalenameWrongLength").html("0");
                $("#addsalenameWrongDiv").removeClass("wrong");
                $("#addsalenameWrong").html('');
                $("#addsalepasswordWrongDiv").removeClass("wrong");
                $("#addsalepasswordWrong").html("");
                $("#addsaletelephonewrongDiv").removeClass("wrong");
                $("#addsaletelephoneWrong").html();
                listRole(null, 2, roleDiv);
                $("#secondPopup").modal("show");
                
                //设置添加销售账号下拉菜单的默认值     
                $("#secondPopup").find(".dropdown-list .select-min li").each(function(){
                    if($(this).children().attr("hrefvalue")==currentOrgId){
                    	$("#secondPopup").find(".dropdown-list .drop-list-min .checked a").text($(this).children().text());
                    	$("#secondPopup").find("#saleTeam").val($(this).children().attr("hrefvalue"));
                    }
                });
              
            }
        }
    }
    function listRole(operator, roleGroupId, roleDiv) {
        var url = "/data/json/roles/group/v3.0";
        $.ajax({
            url : url,
            async : false,
            type : 'post',
            dataType : 'json',
            data : {
                groupId : roleGroupId
            },
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                var str = "";
                $("#" + roleDiv).empty();
                for (var i = 0; i < result.length; i++) {
                    var row = result[i];
                    if (isSelected(operator, row.id)) {
                        str += '<p class="pull-left"><span class="check-box selected" data-id='+row.id+'><i></i></span>&nbsp;&nbsp' + '<span class="check-box-name">' + row.name + '</span></p>';
                    } else {
                        str += '<p class="pull-left"><span class="check-box" data-id='+row.id+'><i></i></span>&nbsp;&nbsp' + '<span class="check-box-name">' + row.name + '</span></p>';
                    }

                }
                $("#" + roleDiv).append(str);
            }
        });
    }

    //添加开发商用户
    function addDevUser(objBtn) {
        var obj = $("#addDevRole p .selected");
        var arr = new Array();
        if ($.trim($("#addname").val()) == "") {
            $("#addnameWrongDiv").addClass("wrong");
            $("#addnameWrong").html('姓名不能为空');
            $("#addname").focus();
            return;
        } else if ($("#addname").val().length > 10) {
            $("#addnameWrongDiv").addClass("wrong");
            $("#addnameWrong").html('姓名不能超过10个字符');
            $("#addname").focus();
            return;
        } else {
            $("#addnameWrongDiv").removeClass("wrong");
            $("#addnameWrong").html('');
        }
        if (!checkTelePhone($("#addtelephone"), 'addtelephoneWrongDiv', 'addtelephoneWrong')) {
            $("#addtelephone").focus();
            return;
        }

        if ($.trim($("#addaccount").val()) == "") {
            $("#addaccountWrongDiv").addClass("wrong");
            $("#addaccountWrong").html('登录账户不能为空');
            $("#addaccount").focus();
            return;
        } else {
            if ($("#addaccount").val().length < 2) {
                $("#addaccountWrongDiv").addClass("wrong");
                $("#addaccountWrong").html('登录账户不能少于2个字符');
                $("#addaccount").focus();
                return;
            }
            if ($("#addaccount").val().length > 15) {
                $("#addaccountWrongDiv").addClass("wrong");
                $("#addaccountWrong").html('登录账户不能超过15个字符');
                $("#addaccount").focus();
                return;
            }
            $("#addaccountWrongDiv").removeClass("wrong");
            $("#addaccountWrong").html('登录账户不能为空');
        }

        if ($.trim($("#addpassword").val()) == "") {
            $("#addpasswordfWrongDiv").addClass("wrong");
            $("#addpasswordfWrong").html('密码不能为空');
            $("#addpassword").focus();
            return;
        } else {
            $("#addpasswordfWrongDiv").removeClass("wrong");
            $("#addpasswordfWrong").html("");
        }

        if ($("#addpassword").val().length < 6 || $("#addpassword").val().length > 20) {
            $("#addpasswordfWrongDiv").addClass("wrong");
            $("#addpasswordfWrong").html('密码长度必须在6到20位之间');
            $("#addpassword").focus();
            return;
        } else {
            $("#addpasswordfWrongDiv").removeClass("wrong");
            $("#addpasswordfWrong").html("");
        }

        if ($("#addpassword").val() != $("#addconfrimpassword").val()) {
            $("#addpasswordWrongDiv").addClass("wrong");
            $("#addpasswordWrong").html('两次密码不一致');
            $("#addpassword").focus();
            return;
        } else {
            $("#addpasswordWrongDiv").removeClass("wrong");
            $("#addpasswordWrong").html("");
        }
        obj.each(function() {
            arr.push($(this).attr("data-id"));
        });

        if (arr.length == 0) {
            saveResult(false, "请选择角色");
            return;
        }
        $.ajax({
            type : "POST",
            dataType : "html",
            url : "/merse/operator/create.htm/V3.0/",
            data : {
                name : $("#addname").val(),
                account : $("#addaccount").val(),
                password : $("#addpassword").val(),
                telephone : $("#addtelephone").val(),
                roleIds : arr.join(","),
                orgId : devOrgId

            },
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                if (result.success) {
                    statusInfo($(objBtn), 1, "操作成功");
                    //alert("操作成功");
                } else {
                    $("#addaccountWrongDiv").addClass("wrong");
                    $("#addaccountWrong").html(result.msg);
                    $("#addaccount").focus();
                }
                //刷新页面
                loadData('dev');
            }
        });
    }

    //添加销售用户
    function addSaleUser(objBtn) {
        $("#addsaletelephonewrongDiv").removeClass("wrong");
        $("#addsaletelephoneWrong").html('');
        var obj = $("#addSaleRole p .selected");
        var arr = new Array();

        if ($.trim($("#addsalname").val()) == "") {
            $("#addsalenameWrongDiv").addClass("wrong");
            $("#addsalenameWrong").html('姓名不能为空');
            $("#addsalname").focus();
            return;
        } else {
            $("#addsalenameWrongDiv").removeClass("wrong");
            $("#addsalenameWrong").html('');
        }

        if (!checkTelePhone($("#addsaltelephone"), 'addsaletelephonewrongDiv', 'addsaletelephoneWrong')) {
            $("#addsaltelephone").focus();
            return;
        }

        if ($.trim($("#addsalaccount").val()) == "") {
            $("#addsaleaccountWrongDiv").addClass("wrong");
            $("#addsaleaccountWrong").html('登录账户不能为空');
            $("#addsaleaccount").focus();
            return;
        }

        if (!validateSaleName($("#addsalname"))) {
            return;
        }
        if (!validateSaleAccount($("#addsalaccount"))) {
            return;
        }
        if($.trim($("#saleTeam").val()) == ""){
        	saveResult(false,"请选择所属销售组");
        	return;
        }
        if ($.trim($("#addsalpassword").val()) == "") {
            $("#addsalepasswordfWrongDiv").addClass("wrong");
            $("#addsalepasswordfWrong").html('密码不能为空');
            return;
        } else {
            $("#addsalepasswordfWrongDiv").removeClass("wrong");
            $("#addsalepasswordfWrong").html('');
        }

        if ($("#addsalpassword").val().length < 6 || $("#addsalpassword").val().length > 20) {
            $("#addsalepasswordfWrongDiv").addClass("wrong");
            $("#addsalepasswordfWrong").html('密码长度必须在6到20位之间');
            $("#addsalpassword").focus();
            return;
        } else {
            $("#addsalepasswordfWrongDiv").removeClass("wrong");
            $("#addsalepasswordfWrong").html('');
        }

        if (!checkAddSalePassword()) {
            return;
        }

        obj.each(function() {
            arr.push($(this).attr("data-id"));
        });

        if (arr.length == 0) {
            saveResult(false, "请选择角色");
            return;
        }

        $.ajax({
            type : "POST",
            dataType : "html",
            url : "/merse/operator/create.htm/V3.0/",
            data : {
                name : $("#addsalname").val(),
                account : $("#addsalaccount").val(),
                password : $("#addsalpassword").val(),
                telephone : $("#addsaltelephone").val(),
                roleIds : arr.join(","),
                orgId : $("#secondPopup").find("#saleTeam").val()
            },
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                if (result.success) {
                    statusInfo($(objBtn), 1, "操作成功");
                    //alert("操作成功");
                    //刷新页面
                    inSaleData($("#saleTeam").val());
                } else {
                    $("#addsaleaccountWrongDiv").addClass("wrong");
                    $("#addsaleaccountWrong").html(result.msg);
                    $("#addsaleaccount").focus();
                }

            }
        });

    }

    //冻结解冻操作  
    function freezeUserOperation(id, type) {
        var url = "/merse/operator/" + id + "/freeze.htm";
        $.ajax({
            url : url,
            async : false,
            type : 'post',
            data : {
                '_method' : 'put'
            },
            dataType : 'json',
            success : function(data) {
                if (data.success) {
                    if (type == 1) {
                        loadData('dev');
                    } else {
                        inSaleData(currentOrgId);
                    }
                } else {
                    saveResult(false, data.msg);
                    //alert(data.msg);
                }

            }
        });

    }
    //解冻   
    function unFreezeOperator(id, type) {
        var url = "/merse/operator/" + id + "/unfreeze.htm";
        $.ajax({
            url : url,
            async : false,
            type : 'post',
            data : {
                '_method' : 'put'
            },
            dataType : 'json',
            success : function(data) {
                if (data.success) {
                    if (type == 1) {
                        loadData('dev');
                    } else {
                        inSaleData(currentOrgId);
                    }
                } else {
                    saveResult(false, data.msg);
                    //alert(data.msg);
                }

            }
        });
    }
    //加载用户数据 
    function getOperatorData(operatorId) {
        var url = "/merse/operator/" + operatorId + "/";
        var data = $.ajax({
            url : url,
            async : false
        }).responseText;
        var result;
        try {
            result = eval(data);
        } catch (e) {
            result = JSON.parse(data);
        }
        return result;
    }

    //加载置业顾问信息
    function getBuildingData(operatorId) {
        var url = "/merse/estate/building_consultant//building/" + operatorId;
        var data = $.ajax({
            url : url,
            type : 'post',
            async : false
        }).responseText;
        var result;
        try {
            result = eval(data);
        } catch (e) {
            result = JSON.parse(data);
        }
        console.log(result);
        return result;
    }

    //是否选择数据
    function isSelected(operator, rowId) {
        if (operator == null || operator == "") {
            return false;
        }

        for (var j = 0; j < operator.operatorRoles.length; j++) {
            if (rowId == operator.operatorRoles[j].role.id) {
                return true;
            }
        }
        return false;
    }
    //修改销售管理
    function updateOperator(objBtn) {
    	//var orgid = $(objBtn).parent().parent().find(".modal-body").find(".market-group").find("#saleTeam").val();
        if ($.trim($("#editName").val()) == "") {
            $("#editnameWrongDiv").addClass("wrong");
            $("#editnameWrong").html('姓名不能为空');
            $("#editName").focus();
            return;
        } else {
            $("#editnameWrongDiv").removeClass("wrong");
            $("#editnameWrong").html('');
        }

        if (!validateEditName($("#editName"))) {
            return;
        }

        if (!checkTelePhone($("#editTelephone"), 'editTelephoneWrongDiv', 'editTelephoneWrong')) {
            $("#editTelephone").focus();
            return;
        }

        var obj = $("#editSaleRole p .selected");
        var arr = new Array();
        obj.each(function() {
            arr.push($(this).attr("data-id"));
        });
        if (arr.length == 0) {
            saveResult(false, "请选择角色");
            return;
        }
        type = $("#editType").val();
        var url = "/merse/operator/update/" + $("#editOperatorId").val() + "/";
        $.ajax({
            url : url,
            async : false,
            type : 'post',
            data : {
                '_method' : 'put',
                name : $("#editName").val(),
                telephone : $("#editTelephone").val(),
                //orgid:orgid,
                roleIds : arr.join(",")
            },
            dataType : 'json',
            success : function(data) {
                if (data.success) {
                    statusInfo($(objBtn), 1, "操作成功");
                    //alert("操作成功");
                    if (type == 1) {
                        loadData('dev');
                    } else {
                        inSaleData(currentOrgId);
                    }
                } else {
                    saveResult(false, data.msg);
                }
            }
        });
    }

    //重置密码
    function resetPassword() {
        var url = "/merse/operator/" + $("#editOperatorId").val() + "/resetPassword.htm";
        $.ajax({
            url : url,
            async : false,
            type : 'post',
            data : {
                '_method' : 'put'
            },
            dataType : 'json',
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                if (result.success) {
                    $("#passwordInfo").html("（重置密码成功!）");
                } else {
                    $("#passwordInfo").html("（" + result.msg + "）");
                }
            }
        });
    }

    function addSale(obj) {
        var stype = $(".stype").find("a").first().hasClass("current");
        if (stype) {
            addBuildingConsultant(obj);
        } else {
            addSaleUser(obj);
        }
    }
    //添加职业顾问
    function addBuildingConsultant(obj) {
        var sex = $(".sex").find("a").first().hasClass("current");
        var show = $(".show").find("a").first().hasClass("current");
        var gender = "WOMAN";
        if (sex) {
            gender = "MAN";
        }
        var displayOnWap = false;
        if (show) {
            displayOnWap = true;
        }

        if (!validateSaleName($("#addsalname"))) {
            return;
        }

        if ($.trim($("#addsalname").val()) == "") {
            $("#addsalenameWrongDiv").addClass("wrong");
            $("#addsalenameWrong").html('姓名不能为空');
            $("#addsalname").focus();
            return;
        } else {
            $("#addsalenameWrongDiv").removeClass("wrong");
            $("#addsalenameWrong").html('');
        }

        if ($.trim($("#addsaltelephone").val()) == "") {
            $("#addsaletelephonewrongDiv").addClass("wrong");
            $("#addsaletelephoneWrong").html("电话不能为空");
            $("#addsaltelephone").focus();
            return;
        } else if ($("#addsaltelephone").val().length != 11 || isNaN($("#addsaltelephone").val())) {
            $("#addsaletelephonewrongDiv").addClass("wrong");
            $("#addsaletelephoneWrong").html("电话只能为11位数字");
            $("#addsaltelephone").focus();
            return;
        } else {
            $("#addsaletelephonewrongDiv").removeClass("wrong");
            $("#addsaletelephoneWrong").html('');
        }

        if ($.trim($("#addsalaccount").val()) == "") {
            $("#addsaleaccountWrongDiv").addClass("wrong");
            $("#addsaleaccountWrong").html('登录账户不能为空');
            $("#addsaleaccount").focus();
            return;
        }

        if ($("#addsalaccount").val().length != 11 || isNaN($("#addsalaccount").val())) {
            $("#addsaleaccountWrongDiv").addClass("wrong");
            $("#addsaleaccountWrong").html('登录账户只能为11位数字');
            $("#addsaleaccount").focus();
            return;
        }
        if($.trim($("#saleTeam").val()) == ""){
        	saveResult(false,"请选择所属销售组");
        	return;
        }
        if (!validateSaleAccount($("#addsalaccount"))) {
            return;
        }

        if ($.trim($("#addsalpassword").val()) == "") {
            $("#addsalepasswordfWrongDiv").addClass("wrong");
            $("#addsalepasswordfWrong").html('密码不能为空');
            return;
        } else {
            $("#addsalepasswordfWrongDiv").removeClass("wrong");
            $("#addsalepasswordfWrong").html('');
        }

        if ($("#addsalpassword").val().length < 6 || $("#addsalpassword").val().length > 20) {
            $("#addsalepasswordfWrongDiv").addClass("wrong");
            $("#addsalepasswordfWrong").html('密码长度必须在6到20位之间');
            $("#addsalpassword").focus();
            return;
        } else {
            $("#addsalepasswordfWrongDiv").removeClass("wrong");
            $("#addsalepasswordfWrong").html('');
        }

        if (!checkAddSalePassword()) {
            return;
        }
        $.ajax({
            type : "POST",
            dataType : "html",
            url : "/merse/estate/building_consultant/add.htm",
            data : {
                name : $("#addsalname").val(),
                userName : $("#addsalaccount").val(),
                password : $("#addsalpassword").val(),
                telphone : $("#addsaltelephone").val(),
                gender : gender,
                displayOnWap : displayOnWap,
                orgId : $("#secondPopup").find("#saleTeam").val(),
                remark : $("#remark").val()
            },
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                if (result.success) {
                    statusInfo($(obj), 1, "操作成功");
                    //刷新页面
                    inSaleData($("#saleTeam").val());
                    $(".sell-group li").removeClass('current');
                    //判断是哪个分组，遂触发点击事件
                    $(".sell-group li").each(function(){
                    	if($(this).children(".group-name").text() == $("#secondPopup").find("#saleTeam").attr("textval")){
                    		$(this).addClass('current');
                    	}
                    })
                    
                    
                } else {
                    saveResult(false, result.msg);
                }
            }
        });

    }
    //初始化数据   
    function editBuilding(operatorId) {
        $("#editBuildingOperatorId").val(operatorId);
        var building = getBuildingData(operatorId);
        console.log("dsfsdfasdfasdfds");
        var gender = building.gender._name;
        var displayOnWap = building.displayOnWap;
        if (gender == "MAN") {
            $(".editsex").find("a").first().addClass("current");
            $(".editsex").find("a").last().removeClass("current");
        } else {
            $(".editsex").find("a").first().removeClass("current");
            $(".editsex").find("a").last().addClass("current");
        }

        if (displayOnWap) {
            $(".editshow").find("a").first().addClass("current");
            $(".editshow").find("a").last().removeClass("current");
        } else {
            $(".editshow").find("a").first().removeClass("current");
            $(".editshow").find("a").last().addClass("current");
        }
        if(building.pic!=null){
        	$(".img").empty();
        	html="<span class='left-con'>头像：</span>";
        	html+=" <p class='modification' style='background: none;'><img id='consultantPic' style='width: 120px;height: 120px;border-radius: 60px; overflow: hidden;' src='"+building.pic+"'></p>";
        	$(".img").html(html);
        }
        $("#iname").val(building.name);
        $("#itelephone").val(building.telphone);
        $("#iusername").val(building.userName);
        $("#editremark").val(building.remark);
        $("#editBuildingInfo").html("（重置后密码为123456）");

        $("#inamewrong").removeClass("wrong");
        $("#itelephone").removeClass("wrong");
        $("#iusernamelength").html(building.userName.length);
        if (building.name != null && building.name != "") {
            $("#inamewronglength").html(building.name.length);
        } else {
            $("#inamewronglength").html(0);
        }
      //设置修改职业顾问下拉菜单的默认值     
        $("#seventhPopup").find(".dropdown-list .select-min li").each(function(){
            if($(this).children().attr("hrefvalue")==currentOrgId){
            	$("#seventhPopup").find(".dropdown-list .drop-list-min .checked a").text($(this).children().text());
            	$("#seventhPopup").find("#saleTeam").val($(this).children().attr("hrefvalue"));
            }
        });
    }
    //重置置业顾问密码
    function resetBuildingPassword() {
        var url = "/merse/estate/building_consultant/resetPWD/" + $("#editBuildingOperatorId").val();
        $.ajax({
            url : url,
            async : false,
            type : 'post',
            dataType : 'json',
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                if (result.success) {
                    $("#editBuildingInfo").html("（重置密码成功!）");
                } else {
                    $("#editBuildingInfo").html("（" + result.msg + "）");
                }
            }
        });
    }

    //更新职业顾问
    function updateBuildingConsultant(obj) {
    	var orgid = $(obj).parent().parent().find(".modal-body").find(".market-group").find("#saleTeam").val();
        var sex = $(".editsex").find("a").first().hasClass("current");
        var show = $(".editshow").find("a").first().hasClass("current");
        var gender = "WOMAN";
        if (sex) {
            gender = "MAN";
        }
        var displayOnWap = false;
        if (show) {
            displayOnWap = true;
        }

        if ($.trim($("#iname").val()) == "") {
            $("#inamewrongDiv").addClass("wrong");
            $("#inamewrong").html('姓名不能为空');
            $("#iname").focus();
            return;
        } else {
            $("#inamewrongDiv").removeClass("wrong");
            $("#inamewrong").html('');
        }

        if (!validateEditSaleName($("#iname"))) {
            return;
        }
        if (!validateEditSaleTele($("#itelephone"))) {
            return;
        }

        if ($("#itelephone").val().length != 11 || isNaN($("#itelephone").val())) {
            $("#itelephonewrongDiv").addClass("wrong");
            $("#itelephonewrong").html("电话只能为11位数字");
            $("#itelephone").focus();
            return;
        } else {
            $("#itelephonewrongDiv").removeClass("wrong");
            $("#itelephonewrong").html('');
        }

        $.ajax({
            type : "POST",
            dataType : "html",
            url : "/merse/estate/building_consultant/" + $("#editBuildingOperatorId").val() + "/update.htm",
            data : {
                '_method' : 'put',
                name : $("#iname").val(),
                telphone : $("#itelephone").val(),
                gender : gender,
                displayOnWap : displayOnWap,
                orgId : orgid,
                remark : $("#editremark").val()

            },
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                if (result.success) {
                    statusInfo($(obj), 1, "操作成功");
                    //刷新页面
                    inSaleData(currentOrgId);
                } else {
                    saveResult(false, result.msg);
                }
            }
        });

    }
    //删除置业顾问
    function doBuildingDele(name, operatorId) {
        $("#deletetitle").html("确认删除：" + name + "?");
        $("#deleteBudingId").val(operatorId);
    }

    //删除置业顾问
    function deleteBuilding(obj) {
        $.ajax({
            type : "POST",
            dataType : "html",
            url : "/merse/estate/building_consultant/" + $("#deleteBudingId").val() + "/delete.htm",
            data : {
                '_method' : 'delete'
            },
            success : function(data) {
                var result;
                try {
                    result = eval(data);
                } catch (e) {
                    result = JSON.parse(data);
                }
                if (result.success) {
                    statusInfo($(obj), 1, "操作成功");
                    //刷新页面
                    inSaleData(currentOrgId);
                } else {
                    saveResult(false, result.msg);
                }
            }
        });
    }
    //验证
    function validateAccount(obj) {
        obj = $(obj);
        var len = obj.val().length;
        $("#accountLength").html(len);
        if (len >= 2 && len <= 15) {
            $("#addaccountWrongDiv").removeClass("wrong");
            $("#addaccountWrong").html('');
        }
        if(len < 2){
            $("#addaccountWrongDiv").addClass("wrong");
            $("#addaccountWrong").html('登录账户不能少于2个字符');
        }
        if (len > 15) {
            $("#addaccountWrongDiv").addClass("wrong");
            $("#addaccountWrong").html('登录账户不能超过15个字符');
        }
    }

    //校验密码
    function checkAddPassword(obj) {
        if ($("#addpassword").val() != $("#addconfrimpassword").val()) {
            $("#addpasswordWrongDiv").addClass("wrong");
            $("#addpasswordWrong").html('两次输入的密码不一致');
        } else {
            $("#addpasswordWrongDiv").removeClass("wrong");
            $("#addpasswordWrong").html("");
        }
    }

    function validateName(obj) {
        obj = $(obj);
        var len = obj.val().length;
        $("#addnameWrongLength").html(len);
        if (len > 0 && len <= 10) {
            $("#addnameWrongDiv").removeClass("wrong");
            $("#addnameWrong").html('');
        }
        if (len > 10) {
            $("#addnameWrongDiv").addClass("wrong");
            $("#addnameWrong").html('姓名不能超过10个字符');
        }
    }

    function validateEditName(obj) {
        obj = $(obj);
        var len = obj.val().length;
        $("#editnameWrongLength").html(len);
        if (len > 0 && len <= 10) {
            $("#editnameWrongDiv").removeClass("wrong");
            $("#editnameWrong").html('');
            return true;
        }
        if (len > 10) {
            $("#editnameWrongDiv").addClass("wrong");
            $("#editnameWrong").html('姓名不能超过10个字符');
            return false;
        }
        return false;
    }

    function validateGroup(obj) {
        obj = $(obj);
        var len = obj.val().length;
        $("#addSaleGroupWrongLength").html(len);
        if (len > 0 && len <= 10) {
            $("#addSaleGroupDiv").removeClass("wrong");
            $("#addSaleGroupWrong").html('');
            return true;
        }
        if (len > 10) {
            $("#addSaleGroupDiv").addClass("wrong");
            $("#addSaleGroupWrong").html('分组名称不能超过10个字符');
            return false;
        }
        return true;
    }

    function validateEditGroup(obj) {
        obj = $(obj);
        var len = obj.val().length;
        $("#editSaleGroupWrongLength").html(len);
        if (len > 0 && len <= 10) {
            $("#editSaleGroupDiv").removeClass("wrong");
            $("#editSaleGroupWrong").html('');
            return true;
        }
        if (len > 10) {
            $("#editSaleGroupDiv").addClass("wrong");
            $("#editSaleGroupWrong").html('分组名称不能超过10个字符');
            return false;
        }
        return true;
    }

    function validateSaleAccount(obj) {
        obj = $(obj);
        var len = obj.val().length;
        var totalLen = $("#saleaccountTotalLength").html();
        $("#saleaccountLength").html(len);
        var stype = $(".stype").find("a").first().hasClass("current");
   
        if(stype){
        	if (len >=11 && len <= totalLen) {
                $("#addsaleaccountWrongDiv").removeClass("wrong");
                $("#addsaleaccountWrong").html('');
                return true;
            }
        	if(len != 11){
                $("#addsaleaccountWrongDiv").addClass("wrong");
                $("#addsaleaccountWrong").html('登录账户只能是11位数字');
                return false;
            }
        }else{
        	if (len >=15 && len <= totalLen) {
                $("#addsaleaccountWrongDiv").removeClass("wrong");
                $("#addsaleaccountWrong").html('');
                return true;
            }
        	if(len < 2){
                $("#addsaleaccountWrongDiv").addClass("wrong");
                $("#addsaleaccountWrong").html('登录账户不能少于2个字符');
                return false;
            }else if(len >=2 && len <= 15){
				 $("#addsaleaccountWrongDiv").removeClass("wrong");
                $("#addsaleaccountWrong").html(''); 
                return true;
			}else{
                $("#addsaleaccountWrongDiv").addClass("wrong");
                $("#addsaleaccountWrong").html('登录账户不能多于15个字符');
                return false;
            }
        }
        
        if (len > totalLen) {
            $("#addsaleaccountWrongDiv").addClass("wrong");
            $("#addsaleaccountWrong").html('登录账户不能超过' + totalLen + '个字符');
            return false;
        }
    }

    //校验密码
    function checkAddSalePassword(obj) {
        if ($("#addsalpassword").val() != $("#addsalconfrimpassword").val()) {
            $("#addsalepasswordWrongDiv").addClass("wrong");
            $("#addsalepasswordWrong").html('两次输入的密码不一致');
            return false;
        } else {
            $("#addsalepasswordWrongDiv").removeClass("wrong");
            $("#addsalepasswordWrong").html("");
            return true;
        }
    }

    function validateSaleName(obj) {
        obj = $(obj);
        var len = obj.val().length;
        $("#addsalenameWrongLength").html(len);
        if (len >= 0 && len <= 10) {
            $("#addsalenameWrongDiv").removeClass("wrong");
            $("#addsalenameWrong").html('');
            return true;
        }
        if (len > 10) {
            $("#addsalenameWrongDiv").addClass("wrong");
            $("#addsalenameWrong").html('姓名不能超过10个字符');
            return false;
        }
    }

    function validateSaleTele(obj) {
        obj = $(obj);
        if ($.trim(obj.val()) == "") {
            $("#addsaletelephonewrongDiv").addClass("wrong");
            $("#addsaletelephoneWrong").html('电话不能为空');
            return false;
        } else {
            $("#addsaletelephonewrongDiv").removeClass("wrong");
            $("#addsaletelephoneWrong").html();
            return true;
        }
    }

    function validateEditSaleTele(obj) {
        obj = $(obj);
        if ($.trim(obj.val()) == "") {
            $("#itelephonewrongDiv").addClass("wrong");
            $("#itelephonewrong").html('电话不能为空');
            return false;
        } else {
            $("#itelephonewrongDiv").removeClass("wrong");
            $("#itelephonewrong").html();
            return true;
        }
    }

    function validateEditSaleName(obj) {
        obj = $(obj);
        var len = obj.val().length;
        $("#inamewronglength").html(len);
        if (len > 0 && len <= 10) {
            $("#inamewrongDiv").removeClass("wrong");
            $("#inamewrong").html('');
            return true;
        }
        if (len > 10) {
            $("#inamewrongDiv").addClass("wrong");
            $("#inamewrong").html('姓名不能超过10个字符');
            return false;
        }
    }

    //清理数据
    function clearData(flag) {
        if (flag == 1) {
            $("#saleaccountTotalLength").html(11);
        } else {
            $("#saleaccountTotalLength").html(15);
        }
        $("#addsalname").val("");
        $("#addsalaccount").val("");
        $("#addsalpassword").val("");
        $("#addsalconfrimpassword").val("");
        $("#addsaltelephone").val("");
        $("#saleaccountLength").html("0");
        $("#addsaleaccountWrongDiv").removeClass("wrong");
        $("#addsaleaccountWrong").html('');
        $("#addsalenameWrongLength").html("0");
        $("#addsalenameWrongDiv").removeClass("wrong");
        $("#addsalenameWrong").html('');
        $("#addsalepasswordWrongDiv").removeClass("wrong");
        $("#addsalepasswordWrong").html("");
        $("#addsalepasswordfWrongDiv").removeClass("wrong");
        $("#addsaletelephonewrongDiv").removeClass("wrong");
        $("#addsaletelephoneWrong").html();
    }

    //校验电话号码
    function checkTelePhone(obj, wrongDiv, messageDiv) {
        obj = $(obj);
        var len = obj.val().length;
        if (len > 0) {
            if (len != 11 || isNaN(obj.val())) {
                $("#" + wrongDiv).addClass("wrong");
                $("#" + messageDiv).html("电话只能为11位数字或不填");
                return false;
            } else {
                $("#" + wrongDiv).removeClass("wrong");
                $("#" + messageDiv).html();
                return true;
            }

        } else {
            $("#" + wrongDiv).removeClass("wrong");
            $("#" + messageDiv).html();
            return true;
        }
    }
    
    function selectLi(obj){
    	$(obj).parent().parent().parent().parent().find("#saleTeam").val($(obj).attr("hrefvalue"));
    	$(obj).parent().parent().parent().parent().find("#saleTeam").attr("textval",$(obj).text());
    }
    
    //清理数据
    function clearData(flag) {
        if (flag == 1) {
            $("#saleaccountTotalLength").html(11);
        } else {
            $("#saleaccountTotalLength").html(15);
        }
        $("#addsalname").val("");
        $("#addsalaccount").val("");
        $("#addsalpassword").val("");
        $("#addsalconfrimpassword").val("");
        $("#addsaltelephone").val("");
        $("#saleaccountLength").html("0");
        $("#addsaleaccountWrongDiv").removeClass("wrong");
        $("#addsaleaccountWrong").html('');
        $("#addsalenameWrongLength").html("0");
        $("#addsalenameWrongDiv").removeClass("wrong");
        $("#addsalenameWrong").html('');
        $("#addsalepasswordWrongDiv").removeClass("wrong");
        $("#addsalepasswordWrong").html("");
        $("#addsalepasswordfWrongDiv").removeClass("wrong");
        $("#addsaletelephonewrongDiv").removeClass("wrong");
        $("#addsaletelephoneWrong").html();
    }

</script>
</body>
</html>